<template>
  <div class="cs-page-container">
    <div class="cs-filter-container">
      <el-date-picker
        v-model="daterangeValue"
        :picker-options="daterangePickerOptions"
        type="daterange"
        align="right"
        unlink-panels
        range-separator="至"
        start-placeholder="起始时间"
        end-placeholder="结束时间"
        value-format="yyyy-MM-dd"
        clearable
        @change="daterangeChangedTimestamp"
      />
      <el-button
        type="primary"
        icon="el-icon-search"
        :loading="listLoading"
        @click="handleFilter"
      >查询</el-button>
      <el-button
        type="info"
        size="small"
        icon="el-icon-refresh-right"
        @click="resetFilter"
      >重置</el-button>
    </div>
    <div class="cs-filter-result">
      <el-table
        v-loading="listLoading"
        :data="list"
        :height="'calc(100vh - 300px)'"
        border
        fit
        size="small"
        highlight-current-row
        element-loading-text="拼命加载中"
        element-loading-spinner="el-icon-loading"
      >
        <el-table-column
          align="center"
          label="渠道"
          prop="appChannel"
        >
        </el-table-column>

        <el-table-column
          align="center"
          label="注册数"
          prop="recordCount"
        >
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
  import DATEPICKER_OPTIONS from '@/config/datepickerOptions'
  import { xhrRegisterRank } from '@/api/analysis'

  export default {
    name: 'RegisterRank',
    data() {
      return {
        list: [],
        channels: [],
        total: 0,
        listQuery: {
          startTime: null,
          endTime: null
        },
        daterangeValue: '',
        daterangePickerOptions: DATEPICKER_OPTIONS.daterangePickerOptions
      }
    },
    created() {
      this.doSearch()
    },
    methods: {
      doSearch() {
        xhrRegisterRank(this.listQuery).then(resp => {
          this.listLoading = false
          this.total = resp.data.count
          this.list = resp.data.list
        })
      }
    }
  }
</script>
